﻿CREATE Procedure [dbo].[sec_CreditReportText]
	(
		@LoanID int
	)
As

IF NOT EXISTS (SELECT * FROM dbo.fs_Loans_Read(@LoanID,DEFAULT))
BEGIN
	RAISERROR ('Access Denied to LoanID: %d', 16, 1,@LoanID)
	RETURN
END

SELECT  t_CreditInfo.*
FROM         t_Borrower INNER JOIN
                      t_Loan_Borrower ON t_Borrower.ID = t_Loan_Borrower.BorrowerID INNER JOIN
                      t_CreditInfo ON t_Borrower.ID = t_CreditInfo.BorrowerID
WHERE LoanID = @LoanID
ORDER BY Pos

